import instance from "../utils/request";

export function simpleChat(userMessage){
    return instance({
        url:'/Gpt/simple-chat',
        method:'post',
        data:userMessage
    }).then(res =>{
        return res;
    }).catch(err =>{
        console.log(err);
    })
}

export function travelRecommendByGpt(travelRecommend) {
    // 确保 data 格式正确
    const requestData = {
        numPeople: travelRecommend.numPeople || 0,
        avgAge: travelRecommend.avgAge || 0,
        destination: travelRecommend.destination || 'string',
        days: travelRecommend.days || 0,
        travelStyle: travelRecommend.travelStyle || 'string',
        budget: travelRecommend.budget || 'string',
        preferences: travelRecommend.preferences || 'string'
    }

    return instance({
        url: '/Gpt/travel-recommend',
        method: 'post',
        data: requestData,
        headers: {
            'Content-Type': 'application/json'
        }
    }).then(res => {
        return res;
    }).catch(err => {
        console.error('GPT推荐请求失败:', err);
        throw err;  // 向上传递错误
    })
}
export function spotAnalysis(analysis){
    return instance({
        url:'/Gpt/spot-analysis',
        method:'post',
        data:analysis
    }).then(res =>{
        return res;
    }).catch(err =>{
        console.log(err);
    })
}

export function continuousChat(content){
    return instance({
        url:'/Gpt/continuous-chat',
        method:'post',
        data:content
    }).then(res =>{
        return res;
    }).catch(err =>{
        console.log(err);
    })
}